﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
using System.Collections;

namespace SocketAPI
{
    public class SocketServerConnThread
    {
        Socket handlerSock;
        Socket serverSock;
        byte[] bytes = new Byte[1024];
        public string data = null;
        ArrayList dataArrayListRef;
        public int bytesRec;
        public int threadIndex;
        public SocketServerConnThread(int ThreadIndex,Socket handler, Socket server, ArrayList dataArrayList)
        {
            this.threadIndex = ThreadIndex;
            this.dataArrayListRef = dataArrayList;
            this.serverSock = server;
            this.handlerSock = handler;
        }
        public void runThread()
        {
            while (true)
            {
                bytes = new byte[1024];
                bytesRec = handlerSock.Receive(bytes);
                data += Encoding.ASCII.GetString(bytes, 0, bytesRec);
                dataArrayListRef.Add(data);
                if (data.IndexOf("<EOF>") > -1)
                {
                    break;
                }
            }
        }
    }
}
